[KYUUBI-7316] Fix parsePropertyFromUrl to remove query string from parsed values#7317
[KYUUBI-7316] Fix parsePropertyFromUrl to remove query string from parsed values#7317wangyum wants to merge 2 commits intoapache:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7317 +/- ##
======================================
Coverage 0.00% 0.00%
======================================
Files 698 698
Lines 43654 43658 +4
Branches 5896 5897 +1
======================================
- Misses 43654 43658 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes an inconsistency in JDBC URL property parsing where parsePropertyFromUrl was incorrectly including query string parameters in property values while extractURLComponents correctly excluded them. This could cause authentication failures when using JWT auth with additional query parameters.
Changes:
- Modified
parsePropertyFromUrlto strip query string portions (everything after?) from parsed property values - Added comprehensive test coverage for both query string and non-query string scenarios
- Ensured both parsing methods return consistent results
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java | Updated parsePropertyFromUrl to remove query string parameters from property values |
| kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/UtilsTest.java | Added tests verifying consistency between parsing methods and correct handling of query strings |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| String value = token.trim().substring((key.trim() + "=").length()); | ||
| // Remove query string part (anything after ?) to match extractURLComponents behavior | ||
| int queryIndex = value.indexOf('?'); | ||
| if (queryIndex > 0) { |
There was a problem hiding this comment.
The condition queryIndex > 0 will fail to handle query strings at the start of the value (e.g., ?param=value). Change the condition to queryIndex >= 0 to correctly handle all cases where a query string is present, including when it appears at position 0.
| if (queryIndex > 0) { | |
| if (queryIndex >= 0) { |
There was a problem hiding this comment.
@copilot-pull-request-reviewer could you also add a test ?
There was a problem hiding this comment.
@Copilot could you also add a test ?
| return token.trim().substring((key.trim() + "=").length()); | ||
| String value = token.trim().substring((key.trim() + "=").length()); | ||
| // Remove query string part (anything after ?) to match extractURLComponents behavior | ||
| int queryIndex = value.indexOf('?'); |
There was a problem hiding this comment.
kyuubi/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/Utils.java
Lines 482 to 514 in dfd9b49
There was a problem hiding this comment.
see https://kyuubi.readthedocs.io/en/master/client/jdbc/kyuubi_jdbc.html#basic-connection-url-format
jdbc:subprotocol://host:port[/catalog]/[schema];<clientProperties;><[#|?]sessionProperties>
We can parse the clientProperties only to get auth property
Why are the changes needed?
Fixed the
parsePropertyFromUrlmethod inUtils.javato properly remove query string parts (everything after ?) from parsed JDBC URL property values, making it consistent with theextractURLComponentsmethod.When parsing JDBC URLs with query strings like:
jdbc:hive2://host:10012/db;auth=JWT?kyuubi.session.cluster=clusterA.The
parsePropertyFromUrlmethod was incorrectly returningJWT?kyuubi.session.cluster=clusterAfor theauthproperty, whileextractURLComponentscorrectly returned onlyJWT. This inconsistency could cause authentication failures in JWT auth scenarios with additional query parameters.How was this patch tested?
Was this patch authored or co-authored using generative AI tooling?
No.